#父类
# class Person(object):
#     def __init__(self,name,age):
#         self.name=name
#         self.age=age
#     def eat(self):
#         print("%s在吃米饭"%self.name)
# # s1 = Person("lili",12)
# # s1.eat()
# # print(s1.name)
# class Student(Person):
#     def __init__(self,name,age):
#         self.age=age
#         #调用父类的方法 super()
#         super().__init__(name,age)
#     def cry(self):
#         print("%s正在哭"%self.name)
#     #重写父类的方法
#     def eat(self):
#         print("%s在吃米饭"%self.name)
#         print("%s在pao"%self.name)
#
# s1 =Student("lili",18)
# s1.eat()
# s1.cry()
#isinstance() 函数来判断一个对象是否是一个已知的类型
# class A:
#     def a(self):
#         print("aaaaa")
# a1 = A()
# print(a1)
# x=isinstance(a1,A)
# print(x)
# b =isinstance(a1,A)
# print(b)
# a2 ="lili"
# b= isinstance(a2,A)
# print(b)
# class B:
#     def a(self):
#         print("zzzzzz")
# a2 = B()
# print(a2)
# b =isinstance(a2,B)
# print(b)
# a3 ="lilei"
# b =isinstance(a3,B)
# print(b)
# class Dog:
#     #类属性 写在初始化函数以外的地方，直接赋值
#     #类属性可以让类直接调用，对象也可直接调用
#     address ="bj"
#     def __init__(self,name,color):
#         #在初始化函数中的属性都是对象属性
#         #对象属性是不能够 呗类名直接调用的
#         self.name = name
#         self.color = color
#         #这个方法对象可以直接调用的 为对象的方法
#         #对象办法是不能够呗类调用的
#     def eat (self):
#         print("%s在吃罐头"%self.name)
# #类函数  在函数名的上一行 添加一条注解@classmethod   然后类函数中的自带参数 就是 cls
#     @classmethod
#     def play(cls):
#         print("正在%s玩"%cls.address)
# d1 =Dog("yangynag","泰迪")
# d1.eat()
# # n = Dog.name
# # print(n)
# #Dog.eat()  类名不能调用对象的方法所以也会报错
# d1.play()
#静态方法
from tkinter.font import names

#使用类方法修改类的属性
# class Car:
#     name="lili"
#
#     def newname(lili,name):
#         lili.name=name
# d =Car()
# print(d.name)
# Car.newname("lala")
# print(Car.name)
# class Dbs(object):
#     def checkphonenumber(self,phonenumber):
#         if len(phonenumber) == 11 and (phonenumber.startswith('13') or phonenumber.startswith('15') or phonenumber.startswith('18')):
#             print("您的手机号可以使用")
#         else:
#             print("您的手机号不可用")
#     def checkemail(self,email):
#         if"@" in email and(email.endswith(".com")):
#             print("邮箱可用")
#         else:
#             print("邮箱不可用")
#     def checkusername(self,name):
#         if name != None and name !=""and name.strip() !="":
#             print("用户名可用")
#         else:
#             print("用户名不能为空")
# u = Dbs()
# u.checkphonenumber("13323312323")
# u.checkemail("2102764996@qq.com")
# u.checkusername(" NONE ")

# u = [] #创建一个列表，把用户信息放进里面
# class Bjbus: #创建一个北京公交的类
#     #在北京公交类创建一个上车的功能
#     def shangche(self):
#         print("车门开了，可以上车")
#     # 在北京公交类创建一个上车的功能
#     def xiache(self):
#         print("后门开了，请下车")
#     def xinxi(self):
#         print("用户信息")
#
#     #创建一个用户类
# class yonghu:
#     def __init__(self,name,card):#初始化函数进行传参
#         self.card = card
#         self.name = name
#     #给用户类·中添加上车属性
#     def shuaka(self):
#         print("刷卡上车")
#         # 逻辑判断，卡余额需要大于两块
#         if self.card >=2:
#             #打印上车并且在表中加入乘客信息
#             print("%s请上车"%self.name)
#             u.append(self.name)
#         else:
#             print("%s余额不足"%self.name)
#
#     def kouqian(self): #扣钱
#         print("%s刷卡再次扣钱，下车%s"%self.name)
#         self .card-=2
#         u.remove(self.name)#再次扣钱意味着下车，下车后移除下车人的名单
#     def dayin(self):
#         print("打印余额")
#         print(self.card)
# u1=yonghu("lili",20)
# u2=yonghu("lil",30)
# u3=yonghu("li",50)
# u4=yonghu("lii",40)
# #三个·上车信息和余额
# b = Bjbus()# 给北京公交添加一个对象
# b.shangche()#对象调用上车功能
# #用户都满足条件，所以都上车了
# u1.shuaka()
# u2.shuaka()
# u3.shuaka()
# u4.shuaka()
#
# b.xinxi()#用户信息
# b.xiache()
# u1.kouqian()
# u2.kouqian()
# l=[]
# class  Cart:
#     def __init__(self,id1):
#         self.id=id1
#     def tianjia(self,p):
#         #print("添加")
#         l.append (p)
#     def shangchu(self,p):
#         #print("删除")
#         l.remove(p)
#     def qingkong(self):
#         l.clear()
#         #print("清空")
#     def jiesuan(self):
#         print("结算")
#         sum=0
#         for p1 in l:
#             sum+=p1.price
#         print(sum)
#     def zhanshi(self):
#         print(l)
#
# class chanpin:
#     def __init__(self,price,id1,name,detail):
#         self.price=price
#         self.id=id1
#         self.name=name
#         self.detail=detail
# p1 = chanpin(44,2,"辣椒","辣")
# p2 = chanpin(77,2,"蜂蜜","甜")
# p3 = chanpin(30,2,"苦瓜","苦")
# p4 = chanpin(10,2,"洗衣粉","香")
# p5 = chanpin(4,2,"酸菜","酸")
# c =Cart(l)
# #添加商品1,3,5
# c.tianjia(p1)
# c.tianjia(p3)
# c.tianjia(p5)
# print(l)
# c.jiesuan()
# c.qingkong()
# print(l)


#父类
# class Person(object):
#     def __init__(self,name):
#         self.name=name
#     def eat(self):
#         print("%s在吃面条"%self.name)
# #




